from dataStructure import LIST, DICT

class SubStore():
    _dir = ""
    _sdsId = ""
    def __init__(self, dir, sdsId):
        self._dir = dir
        self._sdsId = sdsId

class DeepStore(SubStore): # use for DEEP GRAB
    def __init__(self, dir, sdsId):
        super(DeepStore, self).__init__(dir, sdsId)
        self.URLqueue = LIST(dir + "/URLqueue")
        self.URLvisited = LIST(dir + "/URLvisited")
        self.URLfailed = LIST(dir + "/URLfailed")
        self.RESqueue = LIST(dir + "/RESqueue")
        self.RESvisited = LIST(dir + "/RESvisited")
        self.RESfailed = LIST(dir + "/RESfailed")

class RepeatStore(SubStore): # use for REPEAT GRAB
    def __init__(self, dir, sdsId):
        super(RepeatStore, self).__init__(dir, sdsId)
        self._dir = dir
        self.md5 = LIST(dir + "/.visited")

def storeMap(storeType, *args, **kwargs):
    '''
        storeMap 函数根据 storeType 返回一个 subDataStore 的实例
        完整参数 def storeMap(storeType, sdsId, dir):
        sdsId 表示 subDataStoreId，给 subStore 使用
        storeType 表示 subDataStore 的类型
    '''
    if storeType == 1:
        return DeepStore(*args, **kwargs)
    if storeType == 2:
        return RepeatStore(*args, **kwargs)
    return None